package guda.house.dal.dao.impl;

import guda.grape.autogen.common.BaseDAO;
import guda.house.dal.dao.EstateDAO;
import guda.house.dal.dataobject.EstateDO;
import guda.grape.autogen.common.page.BaseQuery;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class EstateDAOImpl extends BaseDAO implements EstateDAO {

    @Override
	public Long insert(EstateDO estate) {
	      try {
                return (Long) getSqlMapperW().insert("estate.insert",estate);
          } catch (Exception e) {
                throw new RuntimeException(e);
          }

	}

    @Override
	public EstateDO getEstateById(Long estateId) {
	    return (EstateDO)getSqlMapClientTemplate().queryForObject("estate.getEstateById", estateId);
	}

    @Override
	public boolean delEstateById(Long estateId) {
	    int num = 0;
        try {
            num = getSqlMapperW().delete("estate.delEstateById",estateId);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        if(num>0){
            return true;
        }else{
            return false;
        }
	}

    @Override
	public List<EstateDO> getEstateByIds(List idsList) {
        Map m = new HashMap();
        m.put("idsList",idsList);
		return getSqlMapClientTemplate().queryForList("estate.selectByIds", m);
	}

    @Override
	public void cleanAutoIncrement(Long estateId) {
	    try {
            getSqlMapperW().update("estate.cleanAutoIncrement",estateId);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
	}

    @Override
    public List<EstateDO> selectForPage(BaseQuery baseQuery) {
        return getSqlMapClientTemplate().queryForList("estate.selectForPage", baseQuery);
    }

    @Override
    public int countForPage(BaseQuery baseQuery) {
        return (Integer)getSqlMapClientTemplate().queryForObject("estate.countForPage",baseQuery);
    }

    @Override
    public void updateByIdSelective(EstateDO estate) {
        try {
            getSqlMapperW().update("estate.updateByIdSelective",estate);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

}

